package lzzy;

public class TestGenericStack {
    public static void main(String[] args) {
        GenericStack<String> stack1 = new GenericStack<>();
        stack1.push("London");
        stack1.push("Paris");
        stack1.push("Berlin");
        System.out.println(stack1.toString());
        GenericStack<Integer> stack2 = new GenericStack<>();
        stack2.push(1);  // 自动装箱 1 到新Integer(1)
        stack2.push(2);
        stack2.push(3);
        System.out.println(stack2.toString());

        // 新增一个实数例子
        GenericStack<Double> stack3 = new GenericStack<>();
        stack3.push(3.5);
        stack3.push(7.8);
        stack3.push(9.8);
        System.out.println(stack3.toString());
        System.out.println(stack3.pop());
        System.out.println(stack3.toString());
    }
}
